/*
 * @Description:格式化时间
 * @Author: 小雨
 * @Date: 2024-06-26 17:08:20
 * @LastEditTime: 2024-06-26 17:26:48
 * @LastEditors: 小雨
 */

function dataStr(value) {
    const dt = new Date(value);

    const y = dt.getFullYear();
    const m = addZero(dt.getMonth());
    const d = addZero(dt.getDate());

    const hh = addZero(dt.getHours());
    const mm = addZero(dt.getMinutes());
    const ss = addZero(dt.getSeconds());

    return `${y}-${m}-${d} ${hh}-${mm}-${ss}`;
}

function addZero(value) {
    return value > 9 ? value : '0' + value;
}

console.log(dataStr(new Date()));

module.exports = {
    dataStr,
};
